\documentclass[E:/GsjzTle/main/main.tex]{subfiles}

\begin{document}

\begin{itemize}
\item
  已知 \(n,k\)，求解：\(G(n, k) = \sum_{i = 1}^n k \bmod i\)
\item
  \(1 \leq n, k \leq 10^9\)
\end{itemize}

\(ans = n \times k - \sum_{i = 1}^n\lfloor\frac{n}{i}\rfloor\times i\)，对于每一个块都是一个公差为
\(\lfloor\frac{n}{i} \rfloor\) 等差数列

\begin{lstlisting}
signed main()
{
	long long n  , k;
	scanf("%lld %lld" , &n , &k);
	long long ans = n * k ;
	for(long long l = 1 , r ; l <= n ; l = r + 1)
	{
		if(k / l != 0) r = min(n , k / (k / l)) ;
		else r = n;  
		ans -= (k / l) * (r - l + 1) * (l + r) / 2;
	}
	printf("%lld\n" , ans);
	return 0;
}
\end{lstlisting}

\end{document}
